package com.doit.demo03;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class demo01_InetAddress {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress ip = InetAddress.getLocalHost();
        System.out.println(ip);

        System.out.println(ip.getHostName());
        System.out.println(ip.getHostAddress());

        InetAddress hostname = InetAddress.getByName("DESKTOP-T10T7CH");
        System.out.println(hostname.getHostAddress());
        System.out.println(hostname.getHostName());

        InetAddress hostIp = InetAddress.getByName("192.168.2.160");
        System.out.println(hostIp.getHostName());
        System.out.println(hostIp.getHostAddress());
    }
}
